package com.allwayz.controller;

import com.allwayz.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author allwayz
 */
@RestController
@RequestMapping("payment")
@Slf4j
public class PaymentController {
    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/ok/{id}")
    public String paymentInfoOk(@PathVariable Integer id){
        log.info("Result: {}",paymentService.paymentInfoOK(id));
        return paymentService.paymentInfoOK(id);
    }

    @GetMapping("/timeout/{id}")
    public String paymentInfoTimeout(@PathVariable Integer id){
        log.info("Result: {}",paymentService.paymentInfoTimeout(id));
        return paymentService.paymentInfoTimeout(id);
    }

    @GetMapping("circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable Integer id){
        log.info("Result : {}",paymentService.paymentCircuitBreaker(id));
        return paymentService.paymentCircuitBreaker(id);
    }

}
